package com.mc.graph;

public class DFS {
	private boolean[] marked;
	private int count;
	public DFS(Graph G, int v){
		marked = new boolean[G.V()];
		dfs(G,v);
	}
	private void dfs(Graph G,int v){
		marked[v] = true;
		count++;
		for(int w:G.adj(v))
			if(!marked[w]) dfs(G,w);
	}
	public boolean marked(int w){
		return marked[w];
	}
	public int count(){
		return count;
	}
}
